//
//  Wifi.swift
//  fho
//
//  Created by 郭颢源 on 2021/3/19.
//

import Foundation
import SystemConfiguration.CaptiveNetwork

func getSSID() -> String? {
    var ssid:String?
    if let interfaces = CNCopySupportedInterfaces() as NSArray? {
        for interface in interfaces {
            //这里的 as! 强制类型转换是可以成功的
            if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
                ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
                break
            }
        }
    }
    return ssid
}
